(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.test.sampleCompany.viewController', viewController);
	viewController.$inject = [ '$scope', 'Constants', 'layoutConfig', 'validatorConfig', 'gridService', 'authService', 'sampleCompanyService' ];
	function viewController($scope, Constants, layoutConfig, validatorConfig, gridService, authService, sampleCompanyService) {
		var ctrl = this, companyInfo = $scope.$stateParams.params;
		ctrl.layoutConfig = layoutConfig;
		ctrl.validatorConfig = validatorConfig;

		ctrl.init = function() {
			var params = {
				companyCode : companyInfo.companyCode
			};
			ctrl.innerGridOptions = gridService.createInnerGridOptions($scope, ctrl.layoutConfig.formConfigs.subCompany.tableConfigs.table);
			ctrl.innerGridOptions.data = 'vm.company.subCompanyList';
			ctrl.siteCodeOptions = sampleCompanyService.getSiteCodeOptions();
			ctrl.companyTypeOptions = sampleCompanyService.getCompanyTypeOptions();
			ctrl.companyTypeLookupOptions = sampleCompanyService.getCompanyTypeLookupOptions();
			ctrl.sensitiveOptions = sampleCompanyService.getSensitiveOptions();
			ctrl.ccyOptions = sampleCompanyService.getCcyOptions();
			ctrl.calendarYear = 2017;
			return authService.view(params).then(function(response) {
				ctrl.company = response.data || companyInfo;
			}, angular.noop);
		};
	}
})(angular);